<?php 
	namespace app\data\model;

	use think\Model;

	/**
	* 商品图片模型
	*/
	class ShopGoodsImages extends Model
	{
		/**
		 * 商品图片
		 * @return [type] [description]
		 */
		public function images()
		{
			return $this->belongsTo('ShopGoods','id');
		}

		/**
		 * 获取封面图片信息
		 * @param  [type] $gid [商品id]
		 * @return [type]      [description]
		 */
		public function goods_cover($gid)
		{
			return $this->where('goods_id',$gid)->where('is_cover',1)->find();
		}

		/**
		 * 获取商品图片
		 * @param  [type] $gid [商品id]
		 * @return [type]      [description]
		 */
		public function goods_images($gid)
		{
			return $this->where('goods_id',$gid)->where('is_cover',0)->select();
		}
	}